//package com.sub.framework.datasource;
//
//import org.apache.shardingsphere.api.sharding.standard.PreciseShardingAlgorithm;
//import org.apache.shardingsphere.api.sharding.standard.PreciseShardingValue;
//
//import java.util.Collection;
//import java.util.Date;
//
///**
// * TODO
// *
// * @author AZHE_SUN
// * @date 2020-9-18 14:52
// **/
//public class CreateTimeShardingAlgorithm implements  PreciseShardingAlgorithm<Date> {
//
//    /**
//     *
//     * @param collection 数据库的名称
//     * @param preciseShardingValue 匹配值
//     * @return
//     */
//    @Override
//    public String doSharding(Collection<String> collection, PreciseShardingValue<Date> preciseShardingValue) {
//        //配置的分库分片的sharding-column对应的值,也就是具体时间
//        String tb_name = preciseShardingValue.getLogicTableName() + "_";
//        Date date = null;
//        date= (Date)preciseShardingValue.getValue();
//        String year = String.format("%tY", date);
//        String mon  = String.format("%tm",date);
//        tb_name = tb_name + year +"_"+ mon;
//        //each为每个库的名字
//        for (String each : collection) {
//            if (each.equals(tb_name))
//                //循环每个库，看哪个库与当前条件匹配
//                return each;
//        }
////            return null;
//
//        return null;
//    }
//}
